/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rubric;

import specifications.Directive;

/**
 *
 * @author Jason
 */
public class RubricDirectivePanel extends javax.swing.JPanel {
    private ScoredDirective directive;
    
    /**
     * Creates new form RubricDirectivePanel
     */
    public RubricDirectivePanel() {
        initComponents();
    }
    public RubricDirectivePanel(ScoredDirective d){
        directive = d;
        initComponents();
        request.setText(d.getDirective().getRequest());
        if (d.getFulfilled() != null){
            if (d.getFulfilled()){
                yes.setSelected(true);
            }else {
                no.setSelected(true);
            }
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jSeparator1 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        request = new javax.swing.JTextArea();
        no = new javax.swing.JRadioButton();
        yes = new javax.swing.JRadioButton();

        request.setLineWrap(true);
        request.setWrapStyleWord(true);
        jScrollPane1.setViewportView(request);

        buttonGroup1.add(no);
        no.setText("No");
        no.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                noActionPerformed(evt);
            }
        });

        buttonGroup1.add(yes);
        yes.setText("Yes");
        yes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                yesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(yes)
                            .addComponent(no))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jScrollPane1))
                    .addComponent(jSeparator1))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(yes)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(no)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void yesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yesActionPerformed
        directive.setFulfilled(true);
        Main.score.updateScore();
        Main.saved = false;
    }//GEN-LAST:event_yesActionPerformed

    private void noActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_noActionPerformed
       directive.setFulfilled(false);
       Main.score.updateScore();
       Main.saved = false;
    }//GEN-LAST:event_noActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JRadioButton no;
    private javax.swing.JTextArea request;
    private javax.swing.JRadioButton yes;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the directive
     */
    public ScoredDirective getDirective() {
        return directive;
    }

    /**
     * @param directive the directive to set
     */
    public void setDirective(ScoredDirective directive) {
        this.directive = directive;
    }

}
